home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1071 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: Michael R Cook <mcook@cognex.com>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Is typeof legal under ANSI C++?
  5. Date: 13 Apr 1996 23:17:37 GMT
  6. Organization: Cognex Corporation
  7. Sender: mcook@cognex.com
  8. Approved: clamage@eng.sun.com (comp.std.c++)
  9. Message-ID: <r468b4yml6.fsf@erawan>
  10. References: <4kgi76$qf1@engnews1.Eng.Sun.COM>
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. X-Nntp-Posting-Host: erawan.cognex.com
  13. X-Newsreader: September Gnus v0.69/Emacs 19.30
  14. Content-Length: 525
  15. Originator: clamage@taumet
  16.  
  17. "I\qaky P\irez Gonz\alez" <inaky@eneline.es> writes:
  18.  
  19. > So, my cuestion is that of the subject. Does typeof() conform to ANSI C++?
  20.  
  21. No, but you're in luck, because you don't really seem to need it:
  22.  
  23. > template<class T>
  24. > class A
  25. > {
  26. > public:
  27.         typedef T type;
  28. >     virtual T& operator [] (unsigned int i) {return 3; };
  29. > };
  30. > template<class T>
  31. > class B
  32. > {
  33. > public:
  34.       virtual T::type operator[] (unsigned int i)
  35. >     {
  36. >         return (*a)[i];
  37. >     };
  38.  
  39. That solution assumes you can modify the definition of `A'.
  40.  
  41. Michael.
  42.  
  43.  
  44. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  45. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  46. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  47. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  48. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  49.